<template>
  <!-- 搜索详情页 -->
  <div class="searchBox">
    <!-- 标题 -->
    <x-header :left-options="{showBack: true,backText:''}" class="headerBox">
      <div class="searchBtn">
        <div class="searchInner flex">
          <x-icon type="ios-search-strong" size="22" class="searchIcon"></x-icon>
          <input
            type="text"
            class="searchInput"
            v-model="keyWord"
            placeholder="搜索内容"
            @keyup.enter="searchClick"
          />
        </div>
      </div>
      <div slot="right" class="headRight">
        <img src="../assets/img/icon_sort.png" alt @click="sortPop=!sortPop" />
      </div>
    </x-header>
    <!-- 筛选弹框 -->
    <div class="sorts" v-if="sortPop">
      <div class="sortList" @click="sortPop=!sortPop">正序</div>
      <div class="sortList" @click="sortPop=!sortPop">倒序</div>
    </div>
    <div class="topHint">
      共找到
      <span>3</span>人
    </div>
    <div v-for="(item,index) in searchList" :key="index" class="listBox flex">
      <img :src="item.img" alt class="userImg" />
      <div class="listContent">
        <div class="headBox flex_sb">
          <div class="titleBox">
            {{item.userName}}
            <img
              v-if="item.sex[0]=='女'"
              src="../assets/img/icon_gril.png"
              class="sexImg"
            />
            <img v-else src="../assets/img/icon_boy.png" alt class="sexImg" />
          </div>
          <div class="certificate">证书：{{item.certificate}}个</div>
        </div>
        <div class="grade">{{item.grade}}</div>
        <div class="infoBox">
          <div class="infoItem">注册编号：{{item.registerNum}}</div>
          <div class="infoItem">注册时间：{{item.registerTime}}</div>
          <div class="infoItem">联系电话：{{item.phone}}</div>
          <router-link to class="infoMore">查看更多</router-link>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { XHeader } from 'vux'

export default {
  components: {
    XHeader
  },
  data() {
    return {
      keyWord: '',
      sortPop: false,
      searchList: [
        {
          id: '1',
          userName: '罗小飞',
          sex: ['女'],
          grade: '二级教练',
          certificate: '3',
          img: require('../assets/img/img_tx_1.png'),
          registerNum: '2131464651321',
          registerTime: '2016-10-11',
          phone: '13565498852',
        },
        {
          id: '2',
          userName: '罗晓飞',
          sex: ['男'],
          grade: '二级教练',
          certificate: '3',
          img: require('../assets/img/img_tx_1.png'),
          registerNum: '2131464651321',
          registerTime: '2016-10-11',
          phone: '13565498852',
        },
        {
          id: '2',
          userName: '罗志祥',
          sex: ['男'],
          grade: '二级教练',
          certificate: '3',
          img: require('../assets/img/img_tx_1.png'),
          registerNum: '2131464651321',
          registerTime: '2016-10-11',
          phone: '13565498852',
        },
      ]
    }
  },
  methods: {
    searchClick() {
      this.$vux.alert.show({
        content: '搜索触发'
      })
    }
  }
}
</script>

<style lang="less" scoped>
.searchBox {
  // 头部导航
  /deep/.headerBox {
    background-color: #fff;
    border-bottom: 1px solid #eee;
    // position: fixed;
    // top:0;
    // left: 0;
    // right: 0;
    // 搜索
    .searchBtn {
      padding: 0 20px;
      margin-top: 10px;
      .searchInner {
        background-color: #f5f5f5;
        border-radius: 10px;
        padding: 10px 20px;
        .searchIcon {
          fill: #6c6c6c;
          margin-right: 10px;
        }
        .searchInput {
          outline: none;
          border: none;
          background-color: #f5f5f5;
        }
      }
    }

    .vux-header-left {
      left: 24px;
      .vux-header-back {
        color: #000;
      }
      .left-arrow:before {
        border-color: #000;
      }
    }
    .vux-header-title {
      color: #000;
      margin: 0 80px;
    }
    .vux-header-right {
      color: #000;
      .headRight {
        img {
          width: 40px;
          padding-left: 30px;
        }
      }
    }
  }
  // 筛选弹框
  .sorts {
    position: absolute;
    top: 100px;
    right: 30px;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 0 10px 5px #ddd;
    z-index: 99;
    &::before {
      content: '';
      width: 0px;
      height: 0px;
      border-left: 10px solid transparent;
      border-right: 10px solid transparent;
      border-bottom: 10px solid #fff;
      position: absolute;
      top: -10px;
      right: 20px;
    }
    .sortList {
      padding: 15px 30px;
      border-bottom: 1px solid #eee;
      img {
        width: 42px;
        height: 40px;
        vertical-align: middle;
        margin-right: 20px;
      }
    }
  }
  .topHint {
    padding: 20px;
    background-color: #f8f9fa;
    font-size: 30px;

    span {
      color: #f91c23;
    }
  }
  .listBox {
    padding: 20px;
    align-items: flex-start;
    border-bottom: 20px solid #f8f9fa;
    line-height: 1.4;
    .userImg {
      width: 120px;
    }
    .listContent {
      margin-left: 20px;

      .headBox {
        .titleBox {
          font-size: 30px;
          font-weight: bold;
          margin-right: 20px;
          img {
            width: 30px;
            height: 30px;
          }
        }
        .certificate {
          padding: 2px 8px;
          margin-right: 10px;
          // margin: 10px 0;
          text-align: center;
          flex-shrink: 0;
          color: #419df3;
          border: 2px solid #419df3;
        }
      }
      .grade {
        width: 120px;
        padding: 2px 8px;
        font-size: 18px;
        margin-right: 10px;
        margin: 10px 0;
        text-align: center;
        flex-shrink: 0;
        background-color: #fae2ce;
        color: #f79146;
      }
      .infoBox {
        .infoItem {
          display: inline-block;
          font-size: 24px;
          width: 49%;
          color: #050404;
          margin-bottom: 5px;
          white-space: nowrap;
          text-overflow: ellipsis;
          overflow: hidden;
        }
        .infoMore {
          display: inline-block;
          font-size: 24px;
          width: 48%;
          margin-bottom: 5px;
          white-space: nowrap;
          text-overflow: ellipsis;
          overflow: hidden;
          color: #53a7f5;
        }
      }
    }
  }
}
</style>